import { applyMiddleware, compose, createStore } from "redux";
import reducers from './reducer' // 合并
import thunk, { ThunkMiddleware } from 'redux-thunk'
// ts  as  强制类型声明  断言
const composeEnhancers = 
    // 浏览器运行后才有window对象
    (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducers, 
    composeEnhancers(
        // 断言   dispatch 异步action   ts -> ThunkMiddleware
        applyMiddleware(thunk as ThunkMiddleware)
    )
)
// rootState  state 状态
// type interface ts 里的类型声明
// rootState自定义类型 
export type rootState = ReturnType<typeof reducers>
export default store;